/**
 * related to header.ui
 * 
 * @Author : 2037630@163.com
 * @Timestamp : 2017-04-18
 */
var log = require('util/log')
var d1 = require('deviceone')
var App = d1.sm('do_App')
var root = ui('$')
var event = require('config/event')
var header_text = ui('header_text')
var right_button = ui('right_button')
var back_icon = ui('back_icon')
var right_container = ui('right_container')

root.on(event.header.loaded,function(config){
	if(!config){
		return 
	}
	
	if(config.title){
		header_text.text = config.title
	}
	
	back_icon.on('touch',function(){
		App.closePage()
	})
	
	if(config.right){
		right_button.text = config.right.text
		right_container.on('touch', function() {
			root.fire(event.header.rightTouch)
		})
	}else{
		right_container.visible =false
	}
})

root.on(event.header.updateTitle,function(title){
	header_text.text = title
})

